<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <div id="app">
    <h3>{{ title }}</h3>
    <div>
      <button @click="count--">-</button>
      <span>{{ count }}</span>
      <button @click="count++">+</button>
    </div>
  </div>
  <script src="./vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        count: 100,
        title: '计数器'
      },
      // 1.创建阶段(准备数据)
      beforeCreate() {
        console.log("beforCreate 响应式数据准备好之前");

      },
      created() {
        console.log("create 相应式数据准备好之后", this.count);
        // 在初始化阶段可以获取数据

      },
      // 2.挂载阶段(渲染模板)
      beforeMount() {
        console.log("beforeMount 模板渲染之前", document.querySelector('h3').innerHTML);

      },
      mounted() {
        console.log("mounted 模板渲染之后", document.querySelector('h3').innerHTML);
      },
      // 3.更新阶段(修改数据 -> 更新视图)
      beforeUpdate() {
        console.log("beforeUpdate 数据修改了，视图还没有更新", this.count, document.querySelector('span').innerHTML);

      },
      updated() {
        console.log("update 数据修改了，视图已经更新", this.count, document.querySelector('span').innerHTML);

      },
      // 4.卸载阶段 控制台命令:app.$destroy()
      beforeDestory() {
        console.log("befoerDestory 卸载前");

      },
      destoryed() {
        console.log("destoryed, 卸载后");

      }
    })
  </script>
</body>

</html>